<!doctype html>
<meta charset="utf-8">
<title></title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
function test_member(name, enabled, target) {
  var status = enabled ? "Enabled" : "Disabled";
  var verb = enabled ? "shows" : "hides";
  test(function() {
    var interface = target(window.TestBinding);
    var descriptor = Object.getOwnPropertyDescriptor(interface, name);
    if (enabled) {
      assert_not_equals(descriptor, undefined);
    } else {
      assert_equals(descriptor, undefined);
    }
  }, status + " preference " + verb + " member controlled by that preference: " + name);
}

var members = [
  'funcControlledAttribute',
  'funcControlledMethod',
  'prefControlledAttribute',
  'prefControlledMethod'
];
var staticMembers = [
  'funcControlledStaticAttribute',
  'funcControlledStaticMethod',
  'funcControlledConst',
  'prefControlledStaticAttribute',
  'prefControlledStaticMethod',
  'prefControlledConst'
];

for (var i = 0; i < members.length; i++) {
  var name = members[i];
  test_member(name + 'Enabled', true, function(o) { return Object.getPrototypeOf(new o()) });
  test_member(name + 'Disabled', false, function(o) { return Object.getPrototypeOf(new o()) });
}
for (var i = 0; i < staticMembers.length; i++) {
  var name = staticMembers[i];
  test_member(name + 'Enabled', true, function(o) { return o; });
  test_member(name + 'Disabled', false, function(o) { return o; });
}

members = [
    'semiExposedBoolFromInterface',
    'boolFromSemiExposedPartialInterface',
    'semiExposedBoolFromPartialInterface',
];
for (const member of members) {
    var interface = new TestBinding();
    async_test(function(t) {
        assert_true(member in interface);
        assert_true(interface[member]);
        let w = new Worker("worker_member_test.js?" + member);
        w.onmessage = t.step_func(function(e) {
            assert_equals(e.data, undefined);
            t.done();
        });
    }, member);
}
</script>
